from tkinter import *
import tkinter as tk
from tkinter import ttk
from PIL import ImageTk
from PIL import Image
from lunar_python import Lunar,Solar
from lunar_python.util import LunarUtil
from datetime import datetime
import textwrap

lunar = Lunar.fromDate(datetime.now())
yl = Solar.fromDate(datetime.now())

def getage1():
    global yl
    yl = yl.next(1)
    global lunar
    lunar=lunar.next(1)
    update_labels()
    return yl,lunar

def getage2():
    global yl
    yl = yl.next(-1)
    global lunar
    lunar=lunar.next(-1)
    update_labels()
    return yl,lunar

def update_labels():
    # 更新日期相关标签
    label01.config(text=yl.getDay())
    label02.config(text=lunar.getPengZuZhi())
    label03.config(text="农历"+lunar.toString()+"(阴历)")
    label04.config(text=('公历 '+str(yl.getYear()) + '年' + str(yl.getMonth()) + '月' +str(yl.getDay()) + '日'+ " 星期" + lunar.getWeekInChinese() +' ' +yl.getXingZuo()+'座'+' (阳历)'))
    label05.config(text=lunar.getYearInGanZhi()+'年')
    label06.config(text=lunar.getMonthInGanZhi()+'月')
    label07.config(text=lunar.getDayInGanZhi() +'日')
    label09.config(text='属'+lunar.getYearShengXiao())
    label10.config(text='属'+lunar.getMonthShengXiao())
    label11.config(text='属'+lunar.getDayShengXiao())
    label12.config(text=lunar.getYearNaYin())
    label13.config(text=lunar.getMonthNaYin())
    label14.config(text=lunar.getDayNaYin())
    label15.config(text=lunar.getYueXiang()+'月')
    label105.config(text=LunarUtil.SEASON[lunar.getMonth()])
    label08.config(text=lunar.getPengZuGan())
    label16.config(text=lunar.getHou() + ' ' + lunar.getWuHou())
    label17.config(text=lunar.getDayPositionXiDesc())
    label18.config(text=lunar.getDayPositionFuDesc())
    label19.config(text=lunar.getDayPositionCaiDesc())
    label20.config(text=lunar.getDayPositionYangGuiDesc())
    label21.config(text=lunar.getDayPositionYinGuiDesc())
    label22.config(text=lunar.getYearXunKong())
    label23.config(text=lunar.getMonthXunKong())
    label24.config(text=lunar.getDayXunKong())
    label25.config(text=lunar.getDayNineStar())
    label26.config(text=lunar.getGong()+'方'+lunar.getXiu()+lunar.getZheng()+lunar.getAnimal()+lunar.getXiuLuck())
    label27.config(text=lunar.getDayShengXiao()+'日冲'+lunar.getDayChongDesc())
    label28.config(text=lunar.getZhiXing())
    label29.config(text=lunar.getDayTianShen()+'('+lunar.getDayTianShenType()+'日)')
    label30.config(text=lunar.getMonthPositionTai())
    label31.config(text=lunar.getDayPositionTai())
    label32.config(text='岁煞'+lunar.getDaySha())
    label33.config(text=lunar.getLiuYao())
    label34.config(text=lunar.getDayLu())
    label35.config(text=sjq + str((lunar.getPrevJieQi()).getSolar()))
    label36.config(text=xjq + str((lunar.getNextJieQi()).getSolar()))
    label37.config(text=textwrap.fill('      '.join(lunar.getDayYi()),27))
    label38.config(text=textwrap.fill('      '.join(lunar.getDayJi()),27))
    label39.config(text=textwrap.fill('      '.join(lunar.getDayJiShen()),27))
    label40.config(text=textwrap.fill('      '.join(lunar.getDayXiongSha()),27))
    label71.config(text=lunar.getDayNineStar().getNameInXuanKong()+lunar.getDayNineStar().getLuckInXuanKong())
    label72.config(text=lunar.getDayNineStar().getNameInQiMen()+lunar.getDayNineStar().getLuckInQiMen())
    
    year_var.set(yl.getYear())
    month_var.set(yl.getMonth())
    day_var.set(yl.getDay())

def get_img(filename, width, height):
    im = Image.open(filename).resize((width, height))
    im = ImageTk.PhotoImage(im)
    return im

def main():
    global label01, label02,label03, label04, label05, label06, label07,label08, label09, label10, label11, label12, label13, label14, label15,label105, label16, label17, label18, label19, label20, label21, label22, label23, label24, label25, label26, label27, label28, label29, label30, label31, label32, label33, label34, label35, label36, label37, label38, label39, label40,label71,label72, year_var, month_var, day_var, sjq, xjq, yi, ji, jishen, XiongSha, xk, qm
    
    sjq = '节气'+ str(lunar.getPrevJieQi()) +': '
    xjq = '节气'+ str(lunar.getNextJieQi()) +': '
    yi = lunar.getDayYi()
    yi = str('      '.join(yi))
    yi = (textwrap.fill(yi,27))
    ji = lunar.getDayJi()
    ji = str('      '.join(ji))
    ji = (textwrap.fill(ji,27))
    jishen = lunar.getDayJiShen()
    jishen = str('      '.join(jishen))
    jishen = (textwrap.fill(jishen,27))
    XiongSha = lunar.getDayXiongSha()
    XiongSha = str('      '.join(XiongSha))
    XiongSha = (textwrap.fill(XiongSha,27))
    jx = lunar.getDayNineStar()
    xk = jx.getNameInXuanKong()+jx.getLuckInXuanKong()
    qm = jx.getNameInQiMen()+jx.getLuckInQiMen()
    aa = (lunar.getPrevJieQi()).getSolar()
    dd = (lunar.getNextJieQi()).getSolar()

    root = Tk()
    root.geometry('913x654+580+100')
    root.resizable(False, False)
    
    # 设置背景图片
    canvas_root = tk.Canvas(root, width=913, height=654)
    im_root = get_img('rl.png', 913, 654)
    tui = PhotoImage(file="tui.png")
    qian = PhotoImage(file="qian.png")
    
    canvas_root.create_image(456, 327, image=im_root)
    canvas_root.pack()

    # 创建所有标签和控件
    label01=tk.Label(root,text=yl.getDay(),fg='red',bg='#FCF8EF',font=('Arial Black', 80))
    label01.pack()
    canvas_root.create_window(456, 180,window=label01)

    # 前一天按钮
    qian = PhotoImage(file="qian.png")
    mButton1 = Button(root, command=getage2, image=qian)
    mButton1.pack()
    canvas_root.create_window(330, 180, window=mButton1)

    # 后一天按钮
    tui = PhotoImage(file="tui.png")
    mButton2 = Button(root, command=getage1, image=tui)
    mButton2.pack()
    canvas_root.create_window(600, 180, window=mButton2)

    # 年份下拉菜单
    year_var = tk.StringVar(value=yl.getYear())
    year_menu = ttk.Combobox(root, textvariable=year_var, width=6, font=('Arial', 14))
    year_menu['values'] = [str(y) for y in range(1900, 2101)]
    year_menu.pack()
    canvas_root.create_window(312, 45, window=year_menu)

    # 月份下拉菜单
    month_var = tk.StringVar(value=yl.getMonth())
    month_menu = ttk.Combobox(root, textvariable=month_var, width=4, font=('Arial', 14))
    month_menu['values'] = [str(m) for m in range(1, 13)]
    month_menu.pack()
    canvas_root.create_window(447, 45, window=month_menu)

    # 日期下拉菜单
    day_var = tk.StringVar(value=yl.getDay())
    day_menu = ttk.Combobox(root, textvariable=day_var, width=4, font=('Arial', 14))
    day_menu['values'] = [str(d) for d in range(1, 32)]
    day_menu.pack()
    canvas_root.create_window(585, 45, window=day_menu)

    # 其他标签
    label02=tk.Label(root,text=lunar.getPengZuZhi(),fg='black',bg='#FCF8EF',font=('Arial', 11))#百忌
    label02.pack()
    
    canvas_root.create_window(154, 518,window=label02)

    # 创建剩余标签
    label08=tk.Label(root,text=lunar.getPengZuGan() ,fg='black',bg='#FCF8EF',font=('Arial', 11))#彭祖
    label08.pack()
    canvas_root.create_window(154, 480,window=label08)

    label44=tk.Label(root,text='相冲',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label44.pack()
    canvas_root.create_window(704, 26,window=label44)

    label45=tk.Label(root,text='值神',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label45.pack()
    canvas_root.create_window(704, 63,window=label45)

    label46=tk.Label(root,text='十二神',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label46.pack()
    canvas_root.create_window(710, 98,window=label46)

    label47=tk.Label(root,text='吉神宜趋',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label47.pack()
    canvas_root.create_window(49, 335,window=label47)

    label48=tk.Label(root,text='彭祖',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    label48.pack()
    canvas_root.create_window(34, 483,window=label48)

    label49=tk.Label(root,text='百忌',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    label49.pack()
    canvas_root.create_window(34, 517,window=label49)

    label50=tk.Label(root,text='月名',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label50.pack()
    canvas_root.create_window(34, 554,window=label50)

    label51=tk.Label(root,text='月相',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label51.pack()
    canvas_root.create_window(34, 591,window=label51)

    label52=tk.Label(root,text='物侯',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label52.pack()
    canvas_root.create_window(34, 625,window=label52)

    label53=tk.Label(root,text='凶煞宜忌',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label53.pack()
    canvas_root.create_window(720, 336,window=label53)

    label54=tk.Label(root,text='本月胎神',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    label54.pack()
    canvas_root.create_window(720, 480,window=label54)

    label55=tk.Label(root,text='今日胎神',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    label55.pack()
    canvas_root.create_window(720, 517,window=label55)

    label56=tk.Label(root,text='岁煞',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label56.pack()
    canvas_root.create_window(705, 553,window=label56)

    label57=tk.Label(root,text='六耀',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label57.pack()
    canvas_root.create_window(705, 588,window=label57)

    label58=tk.Label(root,text='日禄',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    label58.pack()
    canvas_root.create_window(705, 625,window=label58)

    label59=tk.Label(root,text='喜神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label59.pack()
    canvas_root.create_window(302, 360,window=label59)

    label60=tk.Label(root,text='福神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label60.pack()
    canvas_root.create_window(302, 398,window=label60)

    label61=tk.Label(root,text='财神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label61.pack()
    canvas_root.create_window(302, 434,window=label61)

    label62=tk.Label(root,text='阳贵神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label62.pack()
    canvas_root.create_window(533, 380,window=label62)

    label63=tk.Label(root,text='阴贵神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label63.pack()
    canvas_root.create_window(533, 414,window=label63)

    label64=tk.Label(root,text='年',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label64.pack()
    canvas_root.create_window(295, 525,window=label64)

    label65=tk.Label(root,text='月',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label65.pack()
    canvas_root.create_window(295, 560,window=label65)

    label66=tk.Label(root,text='日',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label66.pack()
    canvas_root.create_window(295, 597,window=label66)

    label67=tk.Label(root,text='九星',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label67.pack()
    canvas_root.create_window(526, 507,window=label67)

    label68=tk.Label(root,text='二十八宿',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label68.pack()
    canvas_root.create_window(541, 543,window=label68)

    label69=tk.Label(root,text='玄空',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label69.pack()
    canvas_root.create_window(528, 574,window=label69)

    label70=tk.Label(root,text='奇门',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    label70.pack()
    canvas_root.create_window(528, 606,window=label70)

    label71=tk.Label(root,text=xk,fg='black',bg='#FCF8EF',font=('Arial', 11))
    label71.pack()
    canvas_root.create_window(619, 575,window=label71)

    label72=tk.Label(root,text=qm,fg='black',bg='#FCF8EF',font=('Arial', 11))
    label72.pack()
    canvas_root.create_window(620, 608,window=label72)

    label03=tk.Label(root,text="农历"+lunar.toString()+"(阴历)",fg='black',bg='#FCF8EF',font=('Arial Black', 13))#阴历日期
    
    canvas_root.create_window(449, 286,window=label03)

    label04=tk.Label(root,text=('公历 '+str(yl.getYear()) + '年' + str(yl.getMonth()) + '月' +str(yl.getDay()) + '日'+ " 星期" + lunar.getWeekInChinese() +' ' +yl.getXingZuo()+'座'+' (阳历)'),fg='black',bg='#FCF8EF',font=('Arial Black', 11))#公历
    
    canvas_root.create_window(450, 90,window=label04)

    label05=tk.Label(root,text=lunar.getYearInGanZhi()+'年',fg='red',bg='#FFFFFF',font=('Arial Black', 11))#干支年
    
    canvas_root.create_window(38, 26,window=label05)

    label06=tk.Label(root,text=lunar.getMonthInGanZhi()+'月',fg='red',bg='#FFFFFF',font=('Arial Black', 11))#干支月
    
    canvas_root.create_window(38, 64,window=label06)

    label07=tk.Label(root,text=lunar.getDayInGanZhi() +'日',fg='red',bg='#FFFFFF',font=('Arial Black', 11))#干支日
    
    canvas_root.create_window(38, 98,window=label07)

    label08=tk.Label(root,text=lunar.getPengZuGan() ,fg='black',bg='#FCF8EF',font=('Arial', 11))#彭祖
    
    canvas_root.create_window(154, 480,window=label08)

    label09=tk.Label(root,text='属'+lunar.getYearShengXiao(),fg='black',bg='#FFFFFF',font=('Arial', 11))#干支年生肖
    
    canvas_root.create_window(120, 28,window=label09)

    label10=tk.Label(root,text='属'+lunar.getMonthShengXiao(),fg='black',bg='#FFFFFF',font=('Arial', 11))#干支月生肖
    
    canvas_root.create_window(120, 61,window=label10)

    label11=tk.Label(root,text='属'+lunar.getDayShengXiao(),fg='black',bg='#FFFFFF',font=('Arial', 11))#干支日生肖
    
    canvas_root.create_window(120, 100,window=label11)

    label12=tk.Label(root,text=lunar.getYearNaYin(),fg='black',bg='#FFFFFF',font=('Arial', 11))#纳音年
    
    canvas_root.create_window(196, 28,window=label12)

    label13=tk.Label(root,text=lunar.getMonthNaYin(),fg='black',bg='#FFFFFF',font=('Arial', 11))#纳音月
    
    canvas_root.create_window(196, 61,window=label13)

    label14=tk.Label(root,text=lunar.getDayNaYin(),fg='black',bg='#FFFFFF',font=('Arial', 11))#纳音日
    
    canvas_root.create_window(196, 100,window=label14)

    label15=tk.Label(root,text=lunar.getYueXiang()+'月',fg='black',bg='#FFFFFF',font=('Arial', 11))#月相
    
    canvas_root.create_window(157, 590,window=label15)

    label105=tk.Label(root,text=LunarUtil.SEASON[lunar.getMonth()] ,fg='black',bg='#FFFFFF',font=('Arial', 11))#月名
    
    canvas_root.create_window(157, 553,window=label105)

    label16=tk.Label(root,text=lunar.getHou() + ' ' + lunar.getWuHou(),fg='black',bg='#FFFFFF',font=('Arial', 11))#物候
    
    canvas_root.create_window(157, 625,window=label16)

    label17=tk.Label(root,text=lunar.getDayPositionXiDesc(),fg='black',bg='#FCF8EF',font=('Arial', 11))#喜神方位
    
    canvas_root.create_window(402, 361,window=label17)

    label18=tk.Label(root,text=lunar.getDayPositionFuDesc(),fg='black',bg='#FCF8EF',font=('Arial', 11))#福神方位
    
    canvas_root.create_window(402, 398,window=label18)

    label19=tk.Label(root,text=lunar.getDayPositionCaiDesc(),fg='black',bg='#FCF8EF',font=('Arial', 11))#财神方位
    
    canvas_root.create_window(402, 435,window=label19)

    label20=tk.Label(root,text=lunar.getDayPositionYangGuiDesc(),fg='black',bg='#FCF8EF',font=('Arial', 11))#阳贵神方位
    
    canvas_root.create_window(628, 381,window=label20)

    label21=tk.Label(root,text=lunar.getDayPositionYinGuiDesc(),fg='black',bg='#FCF8EF',font=('Arial', 11))#阴贵神方位
    
    canvas_root.create_window(628, 417,window=label21)

    label22=tk.Label(root,text=lunar.getYearXunKong(),fg='black',bg='#FCF8EF',font=('Arial', 11))#空亡所值年
    
    canvas_root.create_window(402, 525,window=label22)

    label23=tk.Label(root,text=lunar.getMonthXunKong(),fg='black',bg='#FCF8EF',font=('Arial', 11))#空亡所值月
    
    canvas_root.create_window(402, 562,window=label23)

    label24=tk.Label(root,text=lunar.getDayXunKong(),fg='black',bg='#FCF8EF',font=('Arial', 11))#空亡所值日
    
    canvas_root.create_window(402, 598,window=label24)

    label25=tk.Label(root,text=lunar.getDayNineStar(),fg='black',bg='#FCF8EF',font=('Arial', 11))#九星
    
    canvas_root.create_window(628, 508,window=label25)

    label26=tk.Label(root,text=lunar.getGong()+'方'+lunar.getXiu()+lunar.getZheng()+lunar.getAnimal()+lunar.getXiuLuck(),fg='black',bg='#FCF8EF',font=('Arial', 11))#二十八宿
    
    canvas_root.create_window(628, 543,window=label26)

    label27=tk.Label(root,text=lunar.getDayShengXiao()+'日冲'+lunar.getDayChongDesc(),fg='black',bg='#FFFFFF',font=('Arial', 11)) #相冲
    
    canvas_root.create_window(830, 28,window=label27)

    label28=tk.Label(root,text=lunar.getZhiXing(),fg='black',bg='#FFFFFF',font=('Arial', 11)) #值神
    
    canvas_root.create_window(830, 63,window=label28)

    label29=tk.Label(root,text=lunar.getDayTianShen()+'('+lunar.getDayTianShenType()+'日)',fg='black',bg='#FFFFFF',font=('Arial', 11)) #十二神
    
    canvas_root.create_window(830, 99,window=label29)

    label30=tk.Label(root,text=lunar.getMonthPositionTai(),fg='black',bg='#FCF8EF',font=('Arial', 11))#本月胎神
    
    canvas_root.create_window(830, 483,window=label30)

    label31=tk.Label(root,text=lunar.getDayPositionTai(),fg='black',bg='#FCF8EF',font=('Arial', 11))#今日胎神
    
    canvas_root.create_window(830, 519,window=label31)

    label32=tk.Label(root,text='岁煞'+lunar.getDaySha(),fg='black',bg='#FFFFFF',font=('Arial', 11))#岁煞
    
    canvas_root.create_window(828, 553,window=label32)

    label33=tk.Label(root,text=lunar.getLiuYao(),fg='black',bg='#FFFFFF',font=('Arial', 11))#六曜
    
    canvas_root.create_window(828, 589,window=label33)

    label34=tk.Label(root,text=lunar.getDayLu(),fg='black',bg='#FFFFFF',font=('Arial', 11))#日禄
    
    canvas_root.create_window(828, 624,window=label34)

    label35=tk.Label(root,text=sjq + str(aa),fg='black',bg='#FCF8EF',font=('Arial', 11))#上节气
    
    canvas_root.create_window(116, 135,window=label35)

    label36=tk.Label(root,text=xjq + str(dd),fg='black',bg='#FCF8EF',font=('Arial', 11))#下节气
    
    canvas_root.create_window(788, 136,window=label36)
       
    label37=tk.Label(root,text=yi,fg='black',bg='#FFFFFF',font=('Arial', 11))#宜
    
    canvas_root.create_window(118, 253,window=label37)

    label38=tk.Label(root,text=ji,fg='black',bg='#FFFFFF',font=('Arial', 11))#忌
    
    canvas_root.create_window(794, 253,window=label38)

    label39=tk.Label(root,text=jishen,fg='black',bg='#FFFFFF',font=('Arial', 11))#吉神宜趋
    
    canvas_root.create_window(118, 400,window=label39)

    label40=tk.Label(root,text=XiongSha,fg='black',bg='#FFFFFF',font=('Arial', 11))#凶神宜忌
    
    canvas_root.create_window(794, 400,window=label40)

    label44=tk.Label(root,text='相冲',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    
    canvas_root.create_window(704, 26,window=label44)

    label45=tk.Label(root,text='值神',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    
    canvas_root.create_window(704, 63,window=label45)

    label46=tk.Label(root,text='十二神',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    
    canvas_root.create_window(710, 98,window=label46)

    label47=tk.Label(root,text='吉神宜趋',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    
    canvas_root.create_window(49, 335,window=label47)

    label48=tk.Label(root,text='彭祖',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    
    canvas_root.create_window(34, 483,window=label48)

    label49=tk.Label(root,text='百忌',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    
    canvas_root.create_window(34, 517,window=label49)

    label50=tk.Label(root,text='月名',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    
    canvas_root.create_window(34, 554,window=label50)

    label51=tk.Label(root,text='月相',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    canvas_root.create_window(34, 591,window=label51)

    label52=tk.Label(root,text='物侯',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    canvas_root.create_window(34, 625,window=label52)

    label53=tk.Label(root,text='凶煞宜忌',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    canvas_root.create_window(720, 336,window=label53)

    label54=tk.Label(root,text='本月胎神',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(720, 480,window=label54)

    label55=tk.Label(root,text='今日胎神',fg='red',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(720, 517,window=label55)

    label56=tk.Label(root,text='岁煞',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    canvas_root.create_window(705, 553,window=label56)

    label57=tk.Label(root,text='六耀',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    canvas_root.create_window(705, 588,window=label57)

    label58=tk.Label(root,text='日禄',fg='red',bg='#FFFFFF',font=('Arial Black', 11))
    canvas_root.create_window(705, 625,window=label58)

    label59=tk.Label(root,text='喜神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(302, 360,window=label59)

    label60=tk.Label(root,text='福神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(302, 398,window=label60)

    label61=tk.Label(root,text='财神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(302, 434,window=label61)

    label62=tk.Label(root,text='阳贵神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(533, 380,window=label62)

    label63=tk.Label(root,text='阴贵神',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(533, 414,window=label63)

    label64=tk.Label(root,text='年',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(295, 525,window=label64)

    label65=tk.Label(root,text='月',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(295, 560,window=label65)

    label66=tk.Label(root,text='日',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(295, 597,window=label66)

    label67=tk.Label(root,text='九星',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(526, 507,window=label67)

    label68=tk.Label(root,text='二十八宿',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(541, 543,window=label68)

    label69=tk.Label(root,text='玄空',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(528, 574,window=label69)

    label70=tk.Label(root,text='奇门',fg='black',bg='#FCF8EF',font=('Arial Black', 11))
    canvas_root.create_window(528, 606,window=label70)

    label71=tk.Label(root,text=xk,fg='black',bg='#FCF8EF',font=('Arial', 11))
    canvas_root.create_window(619, 575,window=label71)

    label72=tk.Label(root,text=qm,fg='black',bg='#FCF8EF',font=('Arial', 11))
    canvas_root.create_window(620, 608,window=label72)

    def update_date():
        try:
            year = int(year_var.get())
            month = int(month_var.get())
            day = int(day_var.get())
            new_date = datetime(year, month, day)
            global yl, lunar
            yl = Solar.fromDate(new_date)
            lunar = Lunar.fromDate(new_date)
            update_labels()
        except ValueError:
            pass

    # 绑定日期选择事件
    year_menu.bind("<<ComboboxSelected>>", lambda e: update_date())
    month_menu.bind("<<ComboboxSelected>>", lambda e: update_date())
    day_menu.bind("<<ComboboxSelected>>", lambda e: update_date())

    mainloop()

if __name__ == '__main__':
    main()
